package com.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import net.sf.json.JSONObject;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.util.LoggerUtil;
import com.util.QianNiuUtil;

@Controller
@RequestMapping(value="qianNiuController")
public class QianNiuController {
	Logger logger=Logger.getLogger(QianNiuController.class);
	@RequestMapping(value="getAuthQiNiu")
	@ResponseBody
	public Map<String, Object> getAuthQiNiu(HttpServletRequest request){
		Map<String, Object> map=new HashMap<String, Object>();
		JSONObject logs=JSONObject.fromObject(LoggerUtil.getParams(request));
		try {
			String token=QianNiuUtil.getUpToken();
			map.put("token",token);
			logs.put("token", token);
			LoggerUtil.backlogsSuccess(logs, logger);
		} catch (Exception e) {
			e.printStackTrace();
			map.put("code", "101");
			LoggerUtil.backlogsFalseError(logs, logger, e);
		}
		return map;
	}
}
